﻿using AppBox.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Data;
using ZHDJ.Data.DataCaching;
using ZHDJ.Data.Models.Center;
using ZHDJ.WebPage;
using ZHDJ.WebPage.Master;

namespace ZHDJ.Web.PortalParts
{
    public partial class PageMoreLeaderWindow : MorePageMaster
    {
        /// <summary>
        /// 工作室ID
        /// </summary>
        private string BranchID
        {
            get
            {
                return this.Request["BranchID"] ?? "";
            }
        }

        /// <summary>
        /// ID
        /// </summary>
        private string Id
        {
            get
            {
                return this.Request["ID"] ?? "null";
            }
        }

        public string ImgUrl { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {

            LoadData();

        }

        /// <summary>
        /// 加载
        /// </summary>
        public void LoadData()
        {
            using (var DB = new DBInstance().DB)
            {
                var branch = DB.PartyOrgBranchs.Find(BranchID);
                if (branch == null)
                {
                    RedirectToDefault();
                }
                this.litBranchName.Text = string.Format(" <a href='../BranchIndex.aspx?BranchID={0}' class='abranchname'>{1}</a>", BranchID, branch.BranchName);
                ImgUrl = branch.ImageUrl;
            }
            imgBranch.ImageUrl = UpFileBusiness.GetFileUrl(ImgUrl);

            rptPage.DataSource = PartyOrgLeaderWindow.GetGridData(0,9999,BranchID).Tables[0];
            rptPage.DataBind();

            PartyOrgLeaderWindow polw = WebPage.DBPageBase.DB.PartyOrgLeaderWindows.Find(Id);
            if (polw!=null) {
                hdCategory.Value = polw.Category;
            }
            
        }
        public string GetUrl(string url)
        {
            var temp = url;
            if (temp.IndexOf('?') > 0)
            {
                temp = temp + "&BranchID=" + this.BranchID;
            }
            else
            {
                temp = temp + "?BranchID=" + this.BranchID;
            }
            return temp;
        }
    }
}